package com.gitee.wsl.mathematics.geometry.d2.base


class SizeScaleMode(
    val name: String? = null,
    val transform: (item: Size, container: Size) -> Size
) {
    override fun toString(): String = "ScaleMode($name)"

    operator fun invoke(item: Size, container: Size): Size = transform(item, container)

    companion object {
        val COVER: SizeScaleMode = SizeScaleMode("COVER") { i, c -> i * (c / i).maxComponent() }
        val SHOW_ALL: SizeScaleMode = SizeScaleMode("SHOW_ALL") { i, c -> i * (c / i).minComponent() }
        val FIT: SizeScaleMode get() = SHOW_ALL
        val FILL: SizeScaleMode get() = EXACT
        val EXACT: SizeScaleMode = SizeScaleMode("EXACT") { i, c -> c }
        val NO_SCALE: SizeScaleMode = SizeScaleMode("NO_SCALE") { i, c -> i }
    }
}